110 FOR X = 1 TO 11: READ P,D: & "BEEP",P,D *1.25: NEXT X: & "WAIT",1.5
120 DATA 47,5,0,5,37,15,0,5,47,5,0,10,63,5,0,5,37,15,0,5,31,7: REM " 1(C) 3(E) 1(C) 1(LO G) 3(E) 1(HI G)
150 PRINT T$:A$ = "ROUTINE MACHINE IS A VERSATILE UTILITY THAT MAKES IT EASY TO PUT THE POWER AND SPEED OF MACHINE LANGUAGE IN YOUR APPLESOFT PROGRAMS.": & "PRT",A$: GOSUB 8400: & "WAIT",11.5
160 PRINT :A$ = "ROUTINE MACHINE DOES ALL THE WORK FOR YOU -- NO KNOWLEDGE OF MACHINE LANGUAGE PROGRAMMING IS NECESSARY.": & "PRT",A$: GOSUB 8400: & "WAIT",12
170 PRINT :A$ = "SIMPLY CHOOSE THE ROUTINES YOU NEED FROM AN EVER GROWING LIBRARY, AND ROUTINE MACHINE WILL ATTACH THEM TO YOUR PROGRAM. THEN YOU CAN USE EACH ROUTINE WITH A SIMPLE ONE-LINE COMMAND.": & "PRT",A$,39: GOSUB 8400: & "WAIT",16
180 PRINT M$: HTAB 13: PRINT "WATCH THIS...";
190 GOSUB 8400: & "WAIT",5
200 GOSUB 8600: GOSUB 9000: PRINT " NO MODULES APPENDED ": NORMAL : & "WAIT",3
205 U = 15:D = 20:L = 17:R = 40: GOSUB 8100: PRINT "THIS IS THE MENU THAT YOU WILL SEE WHEN YOU START UP THE 'ROUTINE MACHINE'.";: GOSUB 8500: & "WAIT",6: GOSUB 8100: PRINT "LET'S SEE HOW EASY IT CAN BE TO ADD MACHINE-LANGUAGE POWER TO YOUROWN PROGRAMS.";
215 GOSUB 8600: GOSUB 9100: & "WAIT",2: GOSUB 8100: PRINT "THEN WE'LL TYPE IN THENAME OF THE ROUTINE THAT WE WANT TO USE.";: GOSUB 8500: GOSUB 8300: & "WAIT",3: VTAB 8: HTAB 8:A$ = "BEEP.RM": GOSUB 8000
220 & "WAIT",1: PRINT T$"INVOCATION NAME"T$" --> ";: INVERSE : PRINT " ": & "WAIT",2: GOSUB 8100: PRINT "FINALLY, WE'LL TYPE INTHE NAME THAT WE WANT TO CALL THE ROUTINE.";: GOSUB 8500: GOSUB 8300: & "WAIT",2: VTAB 12: HTAB 8:A$ = "BEEP": GOSUB 8000
225 & "WAIT",3: GOSUB 8100: PRINT "THAT'S ALL THAT THERE IS TO IT...";: GOSUB 8500: & "WAIT",3: GOSUB 8100: PRINT "IN A FEW SECONDS, THE ROUTINE IS ATTACHED TOYOUR PROGRAM, AND YOU CAN START USING IT!";: GOSUB 8400: GOSUB 8300: & "WAIT",6
230 GOSUB 8600: GOSUB 9700: & "WAIT",6: GOSUB 8100: PRINT "THIS SHOWS HOW EASY PROGRAMMING CAN BE WITH ROUTINE MACHINE.";: GOSUB 8500: & "WAIT",12: GOSUB 8100: PRINT "THIS IS AN EXAMPLE OF HOW YOU WOULD ACCESS AROUTINE FROM BASIC...";: GOSUB 8500
255 GOSUB 8600: GOSUB 9800: & "WAIT",2: GOSUB 8100: PRINT "THIS OPTION SHOWS US THE NAMES OF ALL THE MODULES CURRENTLY APPENDED.";: GOSUB 8500: & "WAIT",6: GOSUB 8100: PRINT "IF WE WERE USING MORE MODULES, IT MIGHT LOOKLIKE THIS...";: GOSUB 8500
260 & "WAIT",3: GOSUB 8300: FOR X = 2 TO 5: VTAB 1: HTAB 39: PRINT X: READ A$,B$: VTAB X *2 +3: PRINT "#"X TAB( 6)A$ TAB( 23)B$".RM": GOSUB 8400: & "WAIT",.5: NEXT X: & "WAIT",6
265 DATA "PRINT","PRINT USING","SORT","BUBBLE SORT","SEARCH","STRING SEARCH","SOUND","SOUND EFFECTS"
280 GOSUB 8600: GOSUB 9830: & "WAIT",5: GOSUB 8100: PRINT "THIS OPTION WILL HELP US FIND ALL THE PLACESWHERE WE USE ROUTINES IN OUR PROGRAM.";: GOSUB 8500: & "WAIT",6
285 GOSUB 8100: PRINT "LET'S CHOOSE OPTION 1,WHICH WILL FIND ALL OFTHEM.";: GOSUB 8500: & "WAIT",2: GOSUB 8300: VTAB 5: HTAB 1: INVERSE : PRINT "1 ALL SUCH STATEMENTS?": NORMAL : GOSUB 8400: & "WAIT",6
290 GOSUB 8600: GOSUB 9860: & "WAIT",4:U = 14:D = 19: GOSUB 8100: PRINT "THIS SHOWS US ALL THE PLACES WHERE WE USE ROUTINES IN OUR PROGRAM.";: GOSUB 8500: & "WAIT",6
295 GOSUB 8100: PRINT "IF WE WERE MAKING MOREUSE OF ROUTINES, IT MIGHT LOOK LIKE THIS..";: GOSUB 8500: & "WAIT",3: GOSUB 8300:U = 15:D = 20: FOR X = 2 TO 5: READ N,A$,B$: VTAB X *2 +1: HTAB 1: PRINT N TAB( 7)"& "Q$A$Q$","B$: GOSUB 8400: & "WAIT",.5: NEXT X: & "WAIT",6
300 DATA 40,"SOUND","X,15",53,"SORT","A$(FE) TO A$(LE)",75,"PRINT","EDIT$,2.65*1.05;A$",120,"SEARCH","I$(X1),S$,P"
350 HOME : GOSUB 8600: HTAB 12: INVERSE : PRINT "ROUTINE MACHINE": NORMAL : VTAB 3:A$ = "ROUTINE MACHINE ALSO COMES WITH OVER 30 ROUTINES THAT YOU CAN USE RIGHT AWAY. HERE'S WHAT JUST A FEW OF THEM CAN DO FOR YOU:": & "PRT",A$: & "WAIT",6
360 W = 24: GOSUB 8700: INVERSE : GOSUB 8500: PRINT M$T$"BEEP": NORMAL :A$ = "LETS YOU MAKE TONES AND MUSIC EASILY...": & "PRT",A$: & "WAIT",2
370 FOR X = 1 TO 10: & "BEEP", RND(1) *150 +50,10: & "BEEP",0,2: NEXT X: & "WAIT",1: FOR X = 1 TO 26: READ N: & "BEEP",N,15: NEXT X: & "BEEP",114,50: DATA 114,100,89,75,85,85,66,75,75,56,59,56,75,89,114,100,89,134,75,85,89,100,114,152,114,120
380 & "WAIT",1:W = 9: GOSUB 8700: INVERSE : PRINT M$T$"SOUND EFFECTS": GOSUB 8500: NORMAL :A$ = "WILL CREATE ALL THE NOISES YOUR PROGRAMS WILL EVER NEED...": & "PRT",A$: & "WAIT",1: FOR X = 1 TO 10: & "SOUND", RND(1) *256, RND(1) *256: & "BEEP",0,5: NEXT X
390 & "WAIT",5
400 W = 24: GOSUB 8700: GOSUB 8600: INVERSE : PRINT M$"TEXT FORMATTER": NORMAL :A$ = "WILL PRINT YOUR TEXT WITH WORD WRAP, SO THAT WORDS WILL NOT BE BROKEN ACROSS THE END OF A LINE.": & "PRT",A$: & "WAIT",6
415 B$ = "FOUR SCORE AND SEVEN YEARS AGO, OUR FATHERS BROUGHT FORTH ON THIS CONTINENT A NEW NATION CONCEIVED IN LIBERTY AND DEDICATED TO THE PROPOSITION THAT ALL MEN ARE CREATED EQUAL."
420 PRINT T$"HERE'S HOW BASIC PRINTS A SENTENCE:"M$: GOSUB 8500: & "WAIT",3: PRINT B$: GOSUB 8400: & "WAIT",8
450 W = 17: GOSUB 8700: INVERSE : PRINT T$"PRINT USING": NORMAL :A$ = "IS AN EXCELLENT AND VERY COMPACT WAY OF FORMATTING NUMERIC OUTPUT.": & "PRT",A$: GOSUB 8500: & "WAIT",3: PRINT M$"NUMBER FORMAT OUTPUT"
460 PRINT "---------------------------------------": FOR X = 1 TO 3: READ N,A$,B$: PRINT N TAB( 13)Q$A$Q$ TAB( 29)B$: NEXT X: GOSUB 8400
470 DATA 8386.748,"****,**$.00","**$8,386.75",40965,"00/00/00","04/09/65",2653589.79," , , .00","2,653,589.79"
480 & "WAIT",12
500 W = 24: GOSUB 8700: GOSUB 8600: INVERSE : PRINT T$"BUBBLE SORT": NORMAL :A$ = "GIVES YOU A FAST, EASY WAY TO SORT 1-DIMENSIONAL STRING ARRAYS.": & "PRT",A$: & "WAIT",6: PRINT T$"HERE'S A SORT USING BASIC:": LIST 9300,9370: GOSUB 8400
510 & "WAIT",6: & "WINDOW",6: FOR X = 1 TO 6: & "SCROLL 4X","D": FOR N = 1 TO 10: NEXT N: NEXT X: & "WINDOW",1: & "WAIT",1: VTAB 7: PRINT M$"AND HERE'S ONE USING ROUTINE MACHINE:": PRINT M$"9300 & "Q$"SORT"Q$",A$(FE) TO A$(LE)": GOSUB 8400
520 & "WAIT",8
600 W = 24: GOSUB 8700: GOSUB 8600: INVERSE : PRINT "STRING INPUT": NORMAL :A$ = "LETS YOU INPUT ANYTHING, INCLUDING COMMAS AND COLONS...": & "PRT",A$: & "WAIT",6
610 PRINT M$"HERE'S A BASIC 'INPUT' STATEMENT:"T$"50 INPUT "Q$"DATE?"Q$";J$": GOSUB 8500: & "WAIT",4: PRINT M$"THIS IS WHAT HAPPENS WHEN YOU USE IT:"M$: GOSUB 8500: & "WAIT",4: PRINT "DATE?";: INVERSE : PRINT " " CHR$(8);: GOSUB 8400: & "WAIT",2
650 W = 20: GOSUB 8700: GOSUB 8600: INVERSE : PRINT T$"STRING SEARCH": NORMAL :A$ = "GIVES YOU THE CAPABILITY OF FINDING A SUBSTRING WITHIN ANOTHER LARGER STRING, LIKE THE 'INSTR' FUNCTION FOUND IN MANY OTHER BASICS...": & "PRT",A$
660 & "WAIT",8: PRINT M$"EXAMPLE:"T$"60 & "Q$"SEARCH"Q$","Q$"THIS IS A TEST"Q$","Q$"TEST"Q$",P": GOSUB 8500: & "WAIT",4: PRINT M$:A$ = "FINDS " +Q$ +"TEST" +Q$ +" AT POSITION 11 IN " +Q$ +"THIS IS A TEST" +Q$ +", AND RETURNS P = 11.": & "PRT",A$: GOSUB 8500
700 HOME : GOSUB 8600: INVERSE : PRINT T$"FAST BLOAD": NORMAL :A$ = "LETS YOU LOAD BINARY FILES UP TO FIVE TIMES FASTER THAN DOS DOES. HERE'S A LITTLE DEMONSTRATION:": & "PRT",A$: & "WAIT",6
710 PRINT M$:A$ = "FIRST, WE'LL LOAD A HI-RES PICTURE USING A NORMAL DOS 'BLOAD' (STARTING AT THE TONE)": & "PRT",A$: GOSUB 8500: & "WAIT",5: HGR2 : POKE FS,0: CALL 1002: & "BEEP",29,15: & "BEEP",39,15: PRINT M$ CHR$(4)"BLOAD PIC.BLOAD DEMO,A$4000": PR# 0: & "WAIT",6
720 TEXT : GOSUB 8400: & "WAIT",2: VTAB 14:A$ = "NOW, WE'LL LOAD THE SAME PICTURE USING ROUTINE MACHINE'S 'BLOAD'. (STARTING AT THE TONE)": & "PRT",A$: GOSUB 8500: & "WAIT",5: HGR2 : POKE FS,0: & "BEEP",29,15: & "BEEP",39,15: & "BLOAD","PIC.BLOAD DEMO",16384
730 & "WAIT",6: TEXT : GOSUB 8400: & "WAIT",2: VTAB 19: PRINT "SEE THE DIFFERENCE ???": GOSUB 8500
740 & "WAIT",5
800 HOME : GOSUB 8600: INVERSE : PRINT T$"TURTLE GRAPHICS": NORMAL :A$ = "GIVE YOU THE CAPABILITY OF DOING LOGO-STYLE GRAPHICS FROM YOUR BASIC PROGRAM. WATCH THIS...": & "PRT",A$: & "WAIT",8: GOSUB 8400
810 HGR2 : POKE FS,0: HCOLOR= 3: HPLOT 140,96 +20: FOR X = 1 TO 58: READ H,V: HPLOT TO H,V +20: FOR W = 1 TO 35: NEXT W: NEXT X
820 & "WAIT",6: TEXT : GOSUB 8400: & "WAIT",1.5: VTAB 9:A$ = "THIS IS ALL THAT IT TAKES TO MAKE THE DRAWING THAT YOU JUST SAW:": & "PRT",A$: LIST 9400,9450: GOSUB 8500
830 & "WAIT",10: & "HIRES ASCII",Z: POKE -16304,0: POKE -16299,0: GOSUB 8600: & "WAIT",2.5: FOR X = 1 TO 5: READ V,H,A$:V = (V -1) *8 +6:H = (H -1) *7 +4: FOR N = 1 TO LEN(A$):C = ASC( MID$ (A$,N)) -32: IF C THEN DRAW C AT H +(N -1) *7,V
840 NEXT N: NEXT X: GOSUB 8400: & "WAIT",8: HOME : TEXT
850 DATA 141,96,138,99,135,92,145,94,137,104,133,88,151,94,133,108,131,83,156,96,129,111,131,77,161,99,123,113,132,71,165,104,117,114,136,66,168,110,110,113,140,60,169,117,103,110,147,56,169,125,96,106,155,53,168,134,90,99,164,51,164,142
860 DATA 85,91,174,52,158,150,81,81,184,54,150,158,80,71,194,59,140,164,80,59,204,65,129,168,82,47,213,74,116,171,87,35,220,86,103,171,95,23,226,99,89,168,105,12,229,113,74,163,117,3,230,129,60,155
870 DATA 2,2,"Routine Machine even has a Hi-Res",3.5,2,"character set, so that you can",5,2,"put titles on your Hi-Res",6.5,2,"screens...",6.5,23,"(Like This!)"
900 HOME : GOSUB 8600: HTAB 13: INVERSE : PRINT "ROUTINE MACHINE": NORMAL : PRINT :A$ = "THE FOLLOWING ROUTINES ARE INCLUDED WITH 'ROUTINE MACHINE':": & "PRT",A$: PRINT : & "WAIT",5
910 FOR X = 1 TO 30:P = X -2 * INT((X -1)/2) -1: HTAB P *20 +1: READ A$: PRINT A$ MID$ ( CHR$(13),1,P = 1);: & "BEEP",15,1: NEXT X
920 & "WAIT",15: GOSUB 8400
930 GOTO 50
950 DATA "SWAP","PRINT USING","TEXT OUTPUT","STRING INPUT","STRING SEARCH","ARRAY SEARCH","BUBBLE SORT","BEEP","SOUND EFFECTS","FIX LINK FIELDS","ERR","ERR MSSG","GOTO","GOSUB","LINE DATA RESTORE","DATA ELEMENT SELECT","XNUM","MEMORY MOVE"
8000 H = PEEK(36) +1: FOR X = 0 TO LEN(A$): HTAB H: PRINT MID$ (A$,1,X);: & "BEEP",255 * NOT NOT X,1: INVERSE : PRINT MID$ (" ",1,X < > LEN(A$));: NORMAL : & "WAIT",.1: NEXT X: HTAB H + LEN(A$): RETURN
8100 TEXT : & "WINDOW",U,D,L,R: INVERSE : FOR V = U TO D: VTAB V: HTAB 1: PRINT MID$ (SP$,1,R -(D = V) -L +1);: NEXT V: POKE ( PEEK(40) + PEEK(41) *256) + PEEK(36),32: & "WINDOW",U +1,D -1,L +1,R -1: VTAB U +1: HTAB 1: RETURN
9100 HOME : PRINT "INSERT DISK WITH ROUTINE TO BE APPENDED,THEN ENTER NAME OF FILE"T$"('CAT' FOR CATALOG, <RETURN> TO QUIT)"T$"FILE NAME"T$" --> ";: INVERSE : PRINT " " CHR$(8);: NORMAL : RETURN
9300 FOR I = FE TO FL -1
9310 FOR J = I +1 TO FL
9320 IF A$(I) <A$(J) THEN 9360
9330 TEMP$ = A$(I)
9340 A$(I) = A$(J)
9350 A$(J) = TEMP$
9360 NEXT J
9370 NEXT I
9400 HGR2
9410 & "TG",I
9420 FOR X = 1 TO 174 STEP 3
9430 & "TG",M,X
9440 & "TG",T,123
9450 NEXT X
9700 HOME : PRINT "HERE IS A ";: INVERSE : PRINT "COMPLETE";: NORMAL : PRINT " ";:A$ = "APPLESOFT PROGRAM THAT USES A MACHINE LANGUAGE SUBROUTINE WITH THE HELP OF ROUTINE MACHINE:": & "PRT",A$
9800 HOME : HTAB 7: INVERSE : PRINT " *** MODULE REPORT *** ";: NORMAL : HTAB 39: PRINT "1"T$" INVOKED AS: FILE NAME:"T$"#1 BEEP";: HTAB 23: PRINT "BEEP.RM": VTAB 22: PRINT "PRESS 'S' TO SEARCH PROGRAM"M$" OR <RETURN> FOR MENU";: RETURN
9830 HOME : PRINT "SEARCH TYPE: ";: INVERSE : PRINT "AMPERSAND STATEMENTS": NORMAL : PRINT M$"DO YOU WISH TO SEARCH FOR:"T$"1 ALL SUCH STATEMENTS?"T$"2 ALL MODULE INVOCATIONS?"T$"3 INVOCATIONS OF A PARTICULAR MODULE?"
9840 PRINT T$"(PRESS 'T' TO CHANGE SEARCH TYPE,"M$"OR <RETURN> TO QUIT)": RETURN
9860 HOME : HTAB 6: INVERSE : PRINT " *** AMPERSAND STATEMENTS *** ": NORMAL : PRINT M$"20 & "Q$"BEEP"Q$",P,D": VTAB 21: PRINT "PRESS 'S' FOR NEW SEARCH"M$" OR 'L' TO INSPECT LINE"M$" OR <RETURN> FOR MENU": RETURN
9900 X = 127:Y = 25
9910 PRINT "("X","Y")": & "BEEP",X,Y
9920 GET A$
9930 IF A$ = CHR$(11) THEN N = 10: GOTO 9990
9940 IF A$ = CHR$(10) THEN N = -10: GOTO 9990
9950 IF A$ = CHR$(8) THEN N = -1: GOTO 9990
9960 IF A$ = CHR$(21) OR A$ = "U" THEN N = 1: GOTO 9990
9970 IF A$ = " " THEN N = 0: GOTO 9990
9971 IF A$ = "L" THEN Y = Y +5:Y = Y *(Y <256) +255 *(Y >255): GOTO 9910
9972 IF A$ = "S" THEN Y = Y -5:Y = Y *(Y > -1): GOTO 9910
9973 IF A$ = "E" THEN INPUT "P:";X: INPUT "D:";Y: GOTO 9910